home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / program / ratfor.arc / RATFOR.DOC next >
Text File  |  1987-03-18  |  4KB  |  122 lines

  1. ratfor - ratfor preprocessor
  2.      
  3. synopsis:
  4.         ratfor [-l n] [-o output] input
  5.      
  6. Ratfor has the following syntax:
  7.      
  8. prog:   stat
  9.         prog stat
  10.      
  11. stat:   if (...) stat
  12.         if (...) stat else stat
  13.         while (...) stat
  14.         repeat stat
  15.         repeat stat until (...)
  16.         for (...;...;...) stat
  17.         do ... stat
  18.         switch (intexpr) { case val[,val]: stmt ... default: stmt }
  19.         break n
  20.         next n
  21.         return (...)
  22.         digits stat
  23.         { prog }  or  [ prog ]  or  $( prog $)
  24.         anything unrecognizable
  25.      
  26. where stat is any Fortran or Ratfor statement, and intexpr is an
  27. expression that resolves into an integer value.  A statement is
  28. terminated by an end-of-line or a semicolon.  The following translations
  29. are also performed.
  30.      
  31.         <       .lt.    <=      .le.
  32.         ==      .eq.
  33.         !=      .ne.    ^=      .ne.    ~=      .ne.
  34.         >=      .ge.    >       .gt.
  35.         |       .or.    &       .and.
  36.         !       .not.   ^       .not.   ~       .not.
  37.      
  38. Integer constants in bases other that decimal may be specified as
  39. n%dddd...  where n is a decimal number indicating the base and dddd...
  40. are digits in that base.  For bases > 10, letters are used for digits
  41. above 9.  Examples:  8%77, 16%2ff, 2%0010011.  The number is converted
  42. the equivalent decimal value using multiplication; this may cause sign
  43. problems if the number has too many digits.
  44.      
  45. String literals ("..." or '...') can be continued across line boundaries
  46. by ending the line to be continued with an underline.  The underline is
  47. not included as part of the literal.  Leading blanks and tabs on the
  48. next line are ignored; this facilitates consistent indentation.
  49.      
  50.         include file
  51.      
  52. will include the named file in the input.
  53.      
  54.         define (name,value)     or
  55.         define name value
  56.      
  57. defines name as a symbolic parameter with the indicated value.  Names of
  58. symbolic parameters may contain letters, digits, periods, and underline
  59. character but must begin with a letter (e.g.  B.FLAG).  Upper case is
  60. not equivalent to lower case in parameter names.
  61.      
  62.         string name "character string"          or
  63.         string name(size) "character string"
  64.      
  65. defines name to be an integer array long enough to accomodate the ascii
  66. codes for the given character string, one per word.  The last word of
  67. name is initialized to the symbolic parameter EOS, and indicates the end
  68. of string.
  69.  
  70. ----------------------------------------------------------------------
  71. This has been added:
  72.  
  73. switch(getjunk()) {
  74.     case 2:    
  75.         if (somecond)
  76.             "COND true"
  77.         else
  78.             "COND false"
  79.     case 3:
  80.         "CASE 3 handled here.."
  81.     case 4:
  82.         "CASE 4 handled here.."
  83.     case 5:
  84.         "CASE 5 handled here.."
  85.     default:
  86.         "DEFAULT actions.."
  87. }
  88.  
  89. This generates:
  90.  
  91.       I23000=(getjunk())
  92.       goto 23000
  93. 23002 continue
  94.       if(.not.(somecond))goto 23003
  95.       "COND true"
  96.       goto 23004
  97. 23003 continue
  98.       "COND false"
  99. 23004 continue
  100.       goto 23001
  101. 23005 continue
  102.       "CASE 3 handled here.."
  103.       goto 23001
  104. 23006 continue
  105.       "CASE 4 handled here.."
  106.       goto 23001
  107. 23007 continue
  108.       "CASE 5 handled here.."
  109.       goto 23001
  110. 23008 continue
  111.       "DEFAULT actions.."
  112.       goto 23001
  113. 23000 continue
  114.       I23000=I23000-1
  115.       if (I23000.lt.1.or.I23000.gt.4)goto 23008
  116.       goto (23002,23005,23006,23007),I23000
  117. 23001 continue
  118.  
  119.  
  120. Note that, unlike C, ratfor case statements BREAK automatically.
  121.  
  122. əəəəəəə